import Mock from 'mockjs'

/**
 * 获取各个模块的mock
 */
function getModelMocks () {
  let contexts = require.context('@', true, /^\.\/.*\/mock\/mock_index\.js$/)
  contexts.keys().forEach((key, index) => {
    let func = contexts(key).default // 导出默认项
    if (typeof (func) !== 'undefined') {
      for (let obj in func) {
        Mock.mock(func[obj].path, func[obj].type, func[obj].data)
      }
    }
  })
}

export default getModelMocks()
